package com.video.utils;

import org.springframework.stereotype.Component;

public class ResultMap<T> {
    private int code;			//状态码
    private T data;				//数据
    private String message;		//描述信息
    private long count;			//数据长度
    private boolean status;		//状态
    
	public ResultMap() {
		super();
	}


	public ResultMap(boolean status) {
		this.status = status;
	}

	public ResultMap(boolean status, T data) {
		super();
		this.data = data;
		this.status = status;
	}

	public ResultMap(boolean status,String message) {
		super();
		this.message = message;
		this.status = status;
	}

	public ResultMap(int code,long count, T data,boolean status) {
		super();
		this.code = code;
		this.data = data;
		this.count = count;
		this.status = status;
	}
	public ResultMap(int code, boolean status, String message) {
		super();
		this.code = code;
		this.message = message;
		this.status = status;
	}
	
	/**
     * 分页查询成功返回数据
     * @param data
     * @param <T>
     * @return
     */
    public static <T> ResultMap<T> selectLimitBySuccess(int code,long count,T data){
    	return new ResultMap<T>(code,count,data,true);
    }
	/**
     * 分页查询失败返回数据
     * @param message
     * @param <T>
     * @return
     */
    public static <T> ResultMap<T> selectLimitByError(int code,String message){
        return new ResultMap<T>(code,false,message);
    }

	/**
	 * 功能模块成功返回数据--用于增删改
	 * @param <T>
	 * @return
	 */
	public static <T> ResultMap<T> createBySuccess(){
		return new ResultMap<T>(true);
	}

    /**
     * 功能模块成功返回数据--用于查询
     * @param data
     * @param <T>
     * @return
     */
    public static <T> ResultMap<T> createBySuccess(T data){
    	return new ResultMap<T>(true,data);
    }

    /**
     * 功能模块失败返回数据
     * @param message
     * @param <T>
     * @return
     */
    public static <T> ResultMap<T> createByError(String message){
        return new ResultMap<T>(false,message);
    }
    
    
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public T getData() {
		return data;
	}
	public void setData(T data) {
		this.data = data;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public long getCount() {
		return count;
	}
	public void setCount(long count) {
		this.count = count;
	}
	public boolean isStatus() {
		return status;
	}
	public void setStatus(boolean status) {
		this.status = status;
	}
}
